<?php
/**
 * Created by PhpStorm.
 * User: jungshen
 * Date: 2018/7/26
 * Time: 16:09
 */
namespace app\api\middleware;

use think\Request;
/**
 * Class Auth
 * @package app\api\middleware
 */
class Auth
{
    /**
     * @param Request $request
     * @param \Closure $next
     * @return mixed|\think\response\Json
     */
    public function handle($request,\Closure $next)
    {
        $token=$request->param('token');
        if (!($uid=get_login_info($token,'id'))) {
            $data['msg']='请先登录';
            return json($data,403);
        }
        define('UID',$uid);

        return $next($request);
    }
}